package com.tensai.study.新概念.函数式编程.completableFuture;

import java.util.concurrent.CompletableFuture;

/**
 * 整合两个计算结果
 *
 * @author Tensai
 */
public class ThenCombine {
    public static void main(String[] args) {
        thenCombine();
    }

    private static void thenCombine() {
        CompletableFuture.supplyAsync(() -> "Hello")
                .thenApply(s -> s + " World")
                .thenApply(String::toUpperCase)
                .thenCombine(
                        CompletableFuture.completedFuture(" Java"),
                        (s1, s2) -> s1 + s2
                ).thenAccept(System.out::println);
    }
}
